﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.SqlClient;

namespace ECOSYSTEM_DAL
{
    public class ConexionSQL
    {
        private SqlConnection cnn = null;
        private static ConexionSQL UnicaInstancia = null;
        private String CadConex = "Data Source = (local);Initial Catalog = ECOSYSTEM;Integrated Security = true";
        public ConexionSQL() { }
        public static ConexionSQL getInstancia() {
            if (UnicaInstancia == null) {
                UnicaInstancia = new ConexionSQL();
            }
            return UnicaInstancia;
        }
        public IDbConnection getConexion(){
            try
            {
                cnn = new SqlConnection(CadConex);
                return cnn;
            }
            catch (SqlException ex) { throw new Exception(ex.Message); }
            catch (Exception e) { throw new Exception(e.Message); }
        }
    }
}
